package com.itheima;

import java.util.HashMap;
import java.util.Random;
import java.util.Scanner;
import java.util.Set;

public class Demo3 {
    public static void main(String[] args) {
        HashMap<String, String> hm = new HashMap<>();
        hm.put("1930", "乌拉圭");
        hm.put("1934", "意大利");
        hm.put("1938", "意大利");
        hm.put("1950", "乌拉圭");
        hm.put("1954", "西德");
        hm.put("1958", "巴西");
        hm.put("1962", "巴西");
        hm.put("1966", "英格兰");
        hm.put("1970", "巴西");
        hm.put("1974", "西徳");
        hm.put("1978", "阿根廷");
        hm.put("1982", "意大利");
        hm.put("1986", "阿根廷");
        hm.put("1990", "西徳");
        hm.put("1994", "巴西");
        hm.put("1998", "法国");
        hm.put("2002", "巴西");
        hm.put("2006", "意大利");
        hm.put("2010", "西班牙");
        hm.put("2014", "德国");
        hm.put("2018", "法国");

        Scanner sc = new Scanner(System.in);

        System.out.println("请输入年份");
        String year = sc.nextLine();
        if (hm.containsKey(year)) {
            System.out.println(year + "年的世界杯冠军是:" + hm.get(year));
        } else {
            System.out.println(year + "年没有举行世界杯");
        }
        System.out.println("请输入国家:");
        String country = sc.nextLine();
        if (hm.containsValue(country)) {

            Set<String> key = hm.keySet();
            System.out.println(country + "获得世界杯的年份是:");
            for (String s : key) {
                if (hm.get(s).equals(country)) {
                    System.out.println(s);
                }
            }
        } else {
            System.out.println(country + "没有获得世界杯冠军");
        }
    }
}

